﻿@using InfoTech.VinhSon.Bussiness
@model IEnumerable<Category>
@{
    Layout = "~/Views/Shared/_2Column.cshtml";
}
@section rightcolumn
{
    @Html.Action("RightColumn")
}
@section css
{
    <style type="text/css">
        .home-news
        {
            margin-bottom: 10px;
        }
        .home-news a
        {
            text-decoration: none;
            font-weight: bold;
        }
        .home-news .description
        {
            color: #000;
            font-size: 12px;
        }
        .home-news-column1
        {
            width: 480px;
            float: left;
        }
        .home-news-column2
        {
            width: 200px;
            height: 100%;
            float: left;
            padding-left: 10px;
            overflow: auto;
        }
        .home-news .article
        {
            width: 110px;
            text-align: center;
            margin: 0 5px;
            float: left;
            margin-top: 10px;
        }
        .home-news .home-news-column1 a
        {
            font-size: 18px;
        }
        .home-news .article a
        {
            font-size: 12px;
        }
        .home-news .home-news-column2 li
        {
            border-bottom: 1px dotted #ccc;
            margin-bottom: 5px;
            padding: 5px
        }
        .home-news .home-news-column2 a
        {
            font-size: 11px;
        }
        .home-news .home-news-column2 a:hover
        {
            text-decoration: underline;
        }
    </style>
}
@section script
{
    <script type="text/javascript">
        $(document).ready(function () {
            $('.home-news .home-news-column2').css('height', $($('.home-news .home-news-column1')[0]).height());
        })
    </script>
}
<div class="clear">
</div>
@{
    List<Article> list = new List<Article>();
    if (ViewBag.TopArticles != null)
    {
        list.AddRange((List<Article>)ViewBag.TopArticles);
    }
    if (list.Any())
    {
        Article aFirst = list.First();
    <div class="home-news">
        <div class="home-news-column1">
            <a title="@aFirst.Description" href="@aFirst.GetUrl()">
                <img class="img" src="/Resource/Article/@aFirst.Thumbnail" width="170" height="128" style="float: left;margin: 0 10px 5px 0;"/></a>
            <a href="@aFirst.GetUrl()" class="title-brown">@aFirst.Name</a>
            <div class="description">@aFirst.Description</div>
            <div class="clear">
            </div>
            @{
        bool flag = true;
        int count = 0;
        foreach (Article article in list)
        {
            if (flag)
            {
                flag = false;
            }
            else
            {
                count++;
                <div class="article">
                    <a title="@article.Description" href="@article.GetUrl()">
                        <img src="/Resource/Article/@article.Thumbnail" width="105" height="79"/></a>
                    <br />
                    <a title="@article.Description" href="@article.GetUrl()">@article.Name</a>
                </div>
            }
            if (count == 4)
            {
                break;
            }
        }
            }
            <div class="clear">
            </div>
        </div>
        <div class="home-news-column2">
            @{
        if (list.Count > 5)
        {
                <ul>
                    @{
            for (int i = 0; i < list.Count; i++)
            {
                if (i > 4)
                {
                        <li><a href="@list[i].GetUrl()" title="@list[i].Description">@list[i].Name</a></li>
                }
            }
                    }
                </ul>
        }
            }
        </div>
        <div class="clear">
        </div>
    </div>
    
    }
}
@{
    var group = Model.GroupBy(c => c.GroupIndex ?? int.MaxValue);
    foreach (IGrouping<int, Category> categories in group.OrderBy(c => c.Key))
    {
        bool first = true;
        Category categoryFirst = null;
    <ul class="group-home-item">
        @foreach (Category category in categories.OrderBy(c => c.GroupPriority ?? int.MaxValue))
        {
            <li class="@(first ? "first" : "")"><a href="@category.GetUrl()">@category.Name</a></li>
            if (first)
            {
                categoryFirst = category;
                first = false;
            }
        }
        <div class="clear">
        </div>
    </ul>
        if (categoryFirst != null)
        {
    @Html.Action("Category", new { categoryFirst.Id })
        }
    <div class="clear">
    </div>
    }
}
